package cn.vc.shop.entity.dto;

import cn.vc.shop.entity.po.Commodity;
import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.sql.Timestamp;
import java.util.List;

/**
 * @author mo
 * @Description:
 * @日期: 2024-05-02 17:57
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommodityDto {
    private Long id; // 商品ID
    private Long shopId;//商铺ID
    private String coverUrl;//商铺封面
    private String name;//名称
    private String salesType;// 销售类型
    private List<String> introduceUrls;//介绍图片
    private Integer price;//价格
    private Integer limited;//限量
    private Long num = 0L;//商品数量
    private Long commentNum = 0L;//评论数量
    private Double mark;//商品评分
    private Long sales = 0L;//销售额
    private Timestamp sellTime; // 发售时间
    private Timestamp setTime = new Timestamp(System.currentTimeMillis());//创建时间

    public CommodityDto(Commodity commodity) {
        BeanUtils.copyProperties(commodity, this);
        if (commodity.getIntroduceUrls()!=null) this.introduceUrls = JSON.parseArray(commodity.getIntroduceUrls(), String.class);
    }

}
